home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
fkey
/
teleport.sit
/
Teleport 4.1.asm.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-01-07
|
4KB
|
174 lines
/*
Teleport Version 4.1 FKEY ⌐1986,1987 by John Lim
------------------------------------------------
Ñ Version I was written in TML Pascal.
Ñ Version ][ was rewritten in assembly language to reduce its size then
ported to LSC.
Ñ Version 3 patches AppParmHandle so that PackIt and ResEdit work properly.
Ñ Version 4 makes it compatible with all Systems including MultiFinder;
Refer to TN126 on sublaunching and TN180 on MultiFinder.
(27th December 1987).
Ñ Version 4.1 uses PBGetFInfo instead of PBGetCatInfo to get the
Finder Flags and fixes the warning from THINK (enclosed below).
(5th January 1988).
This code can be freely used/modified by anyone provided that my
contribution is acknowledged.
Set tabs to 8.
============================================================================
WARNING from THIMK :
If bit 6 (0x0040) is set in "fdFlags", MultiFinder will ignore
the various flag bits in the application's SIZE resource. These bits
determine whether the application is "MultiFinder-aware" and whether it
is to receive suspend/resume events and background null events. Apple
has acknowledged this as a bug in MultiFinder 1.0. We recommend always
passing 0 for "fdFlags".
MY SOLUTION :
I pass (fdFlags & ffbf) to Launch; that is I clear bit 6.
*/
#include "HFS.h"
#include "StdFilePkg.h"
#include "SegmentLdr.h"
#include "asm.h"
#define KeyMapAddress 0x174
#define thePoint 0x550064
#define NumTypes 1
typedef struct
{
StringPtr pfName;
int param;
int LC; /* Refer to TN126 on Sublaunching */
long ExtBlockLen;
int fFlags;
long LaunchFlags;
} LaunchStruct;
main()
{
SFReply theReply;
ParamBlockRec pB;
LaunchStruct launchRec;
Ptr saveAddress;
/*Debugger();*/
asm
{
MOVE.L #thePoint,-(A7) ; Push Pt
PEA @promptstring ; push promptstring (length = 0)
CLR.L -(A7) ; filefilter = Nil
; SUBQ.L #2,A7 ; If (Button()) display all files
; Button
; TST.W (A7)+
; BEQ.S @APPL_only
BTST #1,KeyMapAddress+7 ; Check for CapsLock key
BEQ.S @APPL_only
MOVE.W #-1,-(A7) ; If (CapsLock) display all files
BRA.S @cont
APPL_only :
MOVE.W #NumTypes,-(A7) ; NumTypes in typelist
cont :
PEA @TypeList ; push typelist
CLR.L -(A7) ; dialoghook = Nil
PEA theReply ; Reply Record to be returned
MOVE.W #2,-(A7) ; SFGetFile routine selector
Pack3
TST.B theReply.good ; if cancel pressed...
BEQ @endit ; bye-bye
;
; Clear Finder Parameters so no documents are opened accidentally.
;
MOVE.L AppParmHandle,A0 ; Set the Finder Parameters...
MOVE.L (A0),A1
CLR.L (A1) ; to zero.
MOVEQ #4,D0
SetHandleSize
;
; Check to see if HFS system. If not under HFS, then we assume
; that no juggling can occur. We clear launchRec.LC to ensure
; that patched 64K Roms handle sublaunching properly.
;
CLR.W launchRec.LC ; This might not be neccessary ?
TST.W FSFCBLen
BLT.S @Not_HFS
;
; Get the Finder Attributes of the application...
;
LEA pB,A0
LEA theReply.fName,A1
MOVE.L A1,pB.fileParam.ioNamePtr
MOVE.W theReply.vRefNum,pB.fileParam.ioVRefNum
CLR.W pB.fileParam.ioFDirIndex
PBGetFInfo
;
; Prepare extensions to launchRec...
;
MOVE.W #'LC',launchRec.LC ; Signature
MOVE.L #6,launchRec.ExtBlockLen ; Length of extensions
MOVE.W pB.fileParam.ioFlFndrInfo.fdFlags,launchRec.fFlags
ANDI.W #0xffbf,launchRec.fFlags ; To remedy MultiFinder1.0 bug,
; as noted by THINK.
;
; Check if WaitNextEvent implemented...
;
MOVE.W #0x9F,D0 ; 0x9F = UnImplemented Trap
GetTrapAddress NEWTOOL
MOVE.L A0,saveAddress
MOVE.W #0xA860,D0 ; 0xA860 = WaitNextEvent
GetTrapAddress NEWTOOL
CMP.L saveAddress,a0
BNE.S @WNE_Exists
CLR.L launchRec.LaunchFlags ; WaitNextEvent not implemented which
; means we want ordinary launching
BRA.S @Not_HFS
WNE_Exists:
MOVE.L #0xC0000000,launchRec.LaunchFlags
; Both highbits must be set when
; sublaunching in MultiFinder.
; Refer to TN180.
Not_HFS :
;
; Set the correct volume.
;
LEA pB,A0 ;prepare ParamBlock
CLR.L pB.volumeParam.ioNamePtr
MOVE.W theReply.vRefNum,pB.volumeParam.ioVRefNum
PBSetVol
;
;
;
LEA launchRec,A0
LEA theReply.fName,A1
MOVE.L A1,launchRec.pfName ; pointer to name of application
CLR.W launchRec.param ; 0 = use main screen/sound buffers
Launch ; Beam us up, Scottie...
BRA.S @endit
TypeList:
dc.l 'APPL'
promptstring:
dc.w 0
dc.l '⌐198','6-88','John',' Lim'
endit:
}
}